package com.example.swagger3code.config;

import io.swagger.annotations.License;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author Yum
 * @version 1.0
 */
@Configuration
@EnableOpenApi
public class SwaggerConfig {

    @Value("${swagger.enable}")
    private boolean enable;

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.OAS_30) // 指定swagger3
                .apiInfo(apiInfo())
                .enable(true); // 是否开启swagger（正式环境下为了安全置为false）
    }

    @Bean
    public ApiInfo apiInfo() {
        return new ApiInfo("Swagger Doc","Yum Api Document","3.0",
                "http://www.ywxw.xyz",
                new Contact("Yum","http://www.ywxw.xyz","1162744696@qq.com"),
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html",new ArrayList<>());
    }
}
